package com.enjoyor.soa.traffic.server.tpcms.dubbo.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.enjoyor.soa.traffic.api.dto.tpcms.PassApplyDto;
import com.enjoyor.soa.traffic.api.service.dubbo.tpcms.IDubboPassApplyService;
import com.enjoyor.soa.traffic.core.tpcms.service.IPassApplyService;
import com.enjoyor.soa.traffic.util.pojo.Page;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

@SuppressWarnings("rawtypes")
@Service(version = "1.0.0", timeout = 4000)
public class DubboPassApplyService implements IDubboPassApplyService {

    @Autowired
    private IPassApplyService passApplyService;

    /**
     * 新增申请信息
     */
    @Override
    public ResultPojo insertPassApply(PassApplyDto passApplyDto, String userName) {
        return new ResultPojo(passApplyService.insertPassApply(passApplyDto, userName));
    }

    /**
     * 删除申请信息
     */
    @Override
    public ResultPojo deletePassApply(String passApplyId, String userName) {
        return new ResultPojo(passApplyService.deletePassApply(passApplyId, userName));
    }

    /**
     * 修改申请信息
     */
    @Override
    public ResultPojo editPassApply(PassApplyDto passApplyDto, String userName) {
        return new ResultPojo(passApplyService.editPassApply(passApplyDto, userName));
    }

    /**
     * 修改申请单状态
     */
    public ResultPojo editPassApplyStatus(String passApplyId, String applyStatusId, String userName) {
        return new ResultPojo(passApplyService.editPassApplyStatus(passApplyId, applyStatusId, userName));
    }

    /**
     * 查询申请信息列表
     */
    @Override
    public ResultPojo getPassApplyList(String passApplyId, String applyPeople, String applyDept, String applyTypeId,
            String applyStartTime, String applyEndTime, String applyStatusId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("passApplyId", passApplyId);
        map.put("applyPeople", applyPeople);
        map.put("applyDept", applyDept);
        map.put("applyTypeId", applyTypeId);
        map.put("applyStartTime", applyStartTime);
        map.put("applyEndTime", applyEndTime);
        map.put("applyStatusId", applyStatusId);
        List<PassApplyDto> passApplyList = passApplyService.getPassApplyList(map);
        return new ResultPojo(passApplyList);
    }

    /**
     * 查询申请信息分页
     */
    @Override
    public ResultPojo getPassApplyPage(Page page) {
        return new ResultPojo(passApplyService.getPassApplyPage(page));
    }

}
